This invention relates to a control system and on-line editing of user program on a programmable controller.
Programmable controllers (PLC) are commonly being used as a control device in factory automation. A PLC is usually comprised of a plurality of units of various kinds combined appropriately together. Examples of such constituent units include a power source unit serving as a power source, a CPU unit for controlling the PLC as a whole, an input unit for inputting signals from switches and sensors that are installed at appropriate positions on a production machine or the like of the factory automation, an output unit for transmitting control outputs to actuators or the like and a communication unit for carrying out processing to a communication network such as carrying out data communications with a programming tool, a monitoring host apparatus and other PLCs.
The control operations by a CPU unit of a PLC starts with an initialization process and then the signals received by the input unit are taken into the I/O memory of the CPU unit (the so-called IN-refresh process). Next, logical calculations are performed on the basis of a user program which is created by using a preliminarily registered program-writing language such as the ladder language and preliminarily registered in a memory (the calculation process), and after the results of this calculation process are transmitted to the output unit by writing them in the I/O memory (the OUT-refresh process), the so-called peripheral service processes are carried out. These processes are thereafter repeated in a cyclic manner but the sequence in which the processes after the initialization is done may be varied. For example, the OUT-refresh and IN-refresh processes (together referred to as the I/O refresh process) may be done first, followed by the calculation process and the peripheral service processes, in this order. In such a case, the first OUT-refresh process will be only for outputting the fixed values resulting from the initialization and the outputting of the calculation results will start from the OUT-refresh process in the next cycle. As another example, the cyclic operation may be in the order of the calculation process, the I/O refresh process and the peripheral service process. In this case, the first calculation process will be carried out on the basis of the fixed values obtained by the initialization process and calculations on the basis of IN data taken in by the IN-refresh process will start from the second cycle of operations.
User programs are created and edited by using a programming tool connected to the PLC through a network. A user program which has been created or edited is downloaded from the programming tool to the PLC and stored in the user memory of the CPU unit. Such a user program includes a logical circuit with a plurality of input joints by means of a ladder program formed with the ladder language. The user program may include as its constituents function blocks, each representing a group of operations as a block. A function block is an assembly of a plurality of calculation circuits made into one component.
There are situations where something wrong may be discovered in a program or something wrong may happen in the operation even after a user program is executed (in the calculation process of the aforementioned cyclic operations) by the CPU unit of a PLC and the production equipment or the like has actually started to operate. In such a situation, the user program must undergo an editing process including additions, deletions and changes. One of the ways to edit a user program in such a situation is the so-called on-line editing where the program is edited while the control by the PLC is being carried out.
A conventional on-line editing method has been to use a programming tool to temporarily add a command such as a jump command immediately before the portion of the user program to be edited. When the PLC carries out the user program, the portion to be edited is thus skipped such that the operation can be continued without stopping the PLC. In the meantime, by this conventional method, a tool is used to carry out the editing of the skipped portion of the program by carrying out adding, deleting and making changes. Japanese Patent Publication Tokkai 2001-142510, for example, disclosed such a technology.
With such a prior art method of on-line editing, it is relatively easy to edit one circuit by one process but it is difficult to correct at once ladder circuits scattered at a plurality of different positions within a user program because it is extremely cumbersome to add a jump command temporarily to each of the plurality of portions of the user program to be edited. Moreover, such jump commands that have been temporarily added must be removed after the editing is completed and this makes the work even more cumbersome. If even one of these temporarily added commands fails to be removed, the edited program will not operate normally.
Conventional on-line editing methods, furthermore, could not work on function blocks. A function block is seldom stored together at one place in a user program. More often than otherwise, function blocks are stored scattered at a plurality of different positions. This is both because the constituent elements of a function block are like subroutine programs to a main ladder program and comprise an instance and a body and because they are usually stored scattered at a plurality of different positions. Thus, if a conventional method of editing an ordinary circuit is applied to a function block, many jump commands will have to be inserted and both the work of inserting these jump commands and that of removing these inserted jump commands after the editing are extremely cumbersome.
Problems about function blocks will be explained further in detail. As will be explained more in detail below with reference to FIG. 8, the user program memory area for storing a user program is divided into a function block recording part (with recording areas) for storing a plurality of body parts of function blocks and a program recording part (with recording areas) for storing, if the ladder program part and function blocks of a main program are inserted, instances that specify input and output of function blocks corresponding to the inserted function blocks. Thus, to edit a function block means to simultaneously edit the instance portions of the input and the output and the body portions of the actual function blocks at the different positions. Thus, the work of inserting and removing jump commands becomes extremely cumbersome, as in the case of editing a plurality of parts of the ladder circuit of a main user program, as described above.
Another problem with the on-line editing is that the portion of the user program being edited is not processed because it is skipped by a jump instruction, and hence if a portion of the program which is indispensable to the control is edited, there is likely to be an adverse effect on the operations of the PLC and accordingly also the operations of the production equipment or the like. In other words, the on-line editing cannot be carried out freely and indiscriminately on any portion of a program.